// 导入需要的config和request
import confing from '../config/config.js';
import request from '../util/request.js';


// 申明请求对象
const calPlanTeamRequest = {
    // calPlan请求的基本url
    BASE_URL : confing.CAL_URL + "/calPlanTeam",


    //计划班组删除按钮事件
    delete(recordId,callback){
        request.delete(this.BASE_URL + "/" + recordId,callback);
    },

    //批量添加计划班组
    adds(teamIds,planId,callback){
        // 拼接URL
        let url = this.BASE_URL + "/adds?t=1";
        if(teamIds != undefined){
            teamIds.forEach(teamId => {
                url += "&teamId=" + teamId;
            });

            url += "&teamId=" + planId;
            request.get( url,callback);
        }
    },

    // 计划班组列表展示 分页
    list(page = 1,limit = 10,calPlanTeam,callbcak){
        // url
        let url = this.BASE_URL + "/list?page=" + page + "&limit=" + limit;
        if(calPlanTeam){
            if(calPlanTeam.recordId){
                url += "&recordId=" + calPlanTeam.recordId;
            }
            if(calPlanTeam.planId){
                url += "&planId=" + calPlanTeam.planId;
            }
        }
        // 发送请求
        request.get(url,callbcak);
    }

}


// 将calPlanTeamRequest暴漏出去
export default calPlanTeamRequest;